# -*- coding:utf-8 -*-
import bluetooth
# 经典蓝牙扫描攻击
def l2capCon(addr, psm):
    sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
    try:
        sock.connect((addr,psm))
        print "[+] l2cap port : " +str(psm)+' open'
        sock.close()
    except Exception,e:
        print '[-] l2cap port :' +str(psm)+' closed'

#测试机
#addr = '22:22:82:8E:CA:64'
#biubiubiubiu
addr = '4C:74:BF:5A:4E:24'

services = bluetooth.find_service(address=addr)
for svc in services:
    print("Service Name: %s" % svc["name"])
    print("    Host:        %s" % svc["host"])
    print("    Description: %s" % svc["description"])
    print("    Provided By: %s" % svc["provider"])
    print("    Protocol:    %s" % svc["protocol"])
    print("    channel/PSM: %s" % svc["port"])
    print("    svc classes: %s " % svc["service-classes"])
    print("    profiles:    %s " % svc["profiles"])
    print("    service id:  %s " % svc["service-id"])
    print("")


for port in range(1, 31):
    l2capCon(addr, port)


